//在request文件下的index.ts配置
 
import axios from "axios"
 
const instance = axios.create({
    baseURL: "https://XXXXXX.com",
    timeout: 20000
})
 
//请求拦截器
instance.interceptors.request.use(
    config => {
        if(localStorage.getItem('token')){
            config.headers.Authorization = localStorage.getItem('token')
        }
        return config
    },
    err => {
        return Promise.reject(err)
    }
)
 
// 响应拦截器
instance.interceptors.response.use(
    res => {
        return res.data
    },
    err => {
        return Promise.reject(err)
    }
)
 
export default instance
 